<?php
/**
* Class and Function List:
* Function list:
* - SelectForm()
* - closegroup()
* - addGroup()
* - addOption()
* - ending()
* - getContent()
*/
class SelectForm
{
    var $_content;
    var $is_open_group;
    function SelectForm($name = '',$attrib = null) 
    {
        if ($name != '') 
	       	$this->_content = '<select name="' . $name . '" id="' . $name . '"';        
        else $this->_content = '<select';
        
        if ( ($attrib) and (is_array($attrib)) )
        	foreach ($attrib as $k => $v)	
        		$this->_content .= ' '.$k.'='.$v;
        			
        $this->_content.=" >";
        $this->is_open_group = false;

    }
    function closegroup() 
    {
        if ($this->is_open_group) $this->_content.= '</optgroup>';
        $this->is_open_group = false;

    }
    function addGroup($label) 
    {
        $this->closegroup();
        $this->_content.= '<optgroup label="' . HTMLOutput::text($label) . '">';
        $this->is_open_group = true;

    }
    function addOption($value, $text) 
    {
        $this->_content.= '<option value="' . $value . '">' . HTMLOutput::text($text) . '</option>';

    }
    function ending() 
    {
        $this->_content.= '</select>';

    }
    function getContent() 
    {
        $this->ending();
        return $this->_content;

    }

}
?>
